#!/usr/bin/python
# -*-coding: UTF-8 -*-
"""
# Time: 2024/5/22 21:45
# @Author: 修养
# @Project_name: PROJECT_NAME
"""
import json
lists = [1, 2, 3, 4]
listToJson = json.dumps(lists)
print("List转Json字符串：",type(listToJson), listToJson)

dicts = {"name": "周恩来", "age": 28, "hobby": ["看书", "写字"]}
dictToJson = json.dumps(dicts)
print("Dict转Json字符串：", type(dictToJson), dictToJson)


print("~~~~~~~~~~json字符串必须是单引号~~~~~~~~~~~~~~~~")
listStr = '["宋远桥", "张翠山", "殷梨亭", "莫声谷"]'
print(listStr, type(listStr))
# listStr = "[1, 2, 3]"
jsonStrToList = json.loads(listStr)
print("json字符串转List：", type(jsonStrToList), jsonStrToList)
dicsStr = '{"name": "周恩来", "age": 28}'
jsonStrToDict = json.loads(dicsStr)
print("json字符串转dict：", jsonStrToDict)